/*
 * soft_spi.h
 *
 *  Created on: 2025年4月27日
 *      Author: cmy_j
 */

#ifndef MAIN_SOFT_SPI_H_
#define MAIN_SOFT_SPI_H_

#include <stdint.h>
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_chip_info.h"
#include "esp_flash.h"
#include "esp_timer.h"

//-----------------SPI端口移植---------------- 
#define SPI_SCLK  	1
#define SPI_RCK    	2
#define SPI_MRES  	3
#define SPI_MOSI  	4


//-----------------SPI端口定义---------------- 

#define SPI_SCLK_Clr() gpio_set_level(SPI_SCLK, 0)
#define SPI_SCLK_Set() gpio_set_level(SPI_SCLK, 1)

#define SPI_MOSI_Clr() gpio_set_level(SPI_MOSI, 0)
#define SPI_MOSI_Set() gpio_set_level(SPI_MOSI, 1)

#define SPI_MRES_Clr()  gpio_set_level(SPI_MRES, 0)
#define SPI_MRES_Set()  gpio_set_level(SPI_MRES, 1)

#define SPI_RCK_Clr()   gpio_set_level(SPI_RCK, 0)
#define SPI_RCK_Set()   gpio_set_level(SPI_RCK, 1)


void delay_us(uint32_t us);
void delay_ms(uint32_t ms);
void SPI_GPIO_Init(void);//初始化GPIO
void SPI_Writ_Bus(uint8_t dat);//模拟SPI时序
void SPI_WR_DATA8(uint8_t dat);//写入一个字节
void SPI_WR_DATA(uint64_t dat);//写入两个字节



#endif /* MAIN_SOFT_SPI_H_ */
